from pydantic import BaseModel
from typing import Optional
from datetime import datetime


class AnswerBase(BaseModel):
    exam_id: int
    question_id: int
    answer_content: str


class AnswerCreate(AnswerBase):
    pass


class AnswerResponse(AnswerBase):
    id: int
    user_id: int
    is_correct: bool
    score: float
    answered_at: datetime

    class Config:
        from_attributes = True


class AnswerSubmit(BaseModel):
    question_id: int
    answer: str


class ExamSubmit(BaseModel):
    answers: list[AnswerSubmit]